var ibmdb = require('ibm_db');
// var connStr = "DATABASE=sample;HOSTNAME=10.10.3.12;UID=db2inst1;PWD=12345678;PORT=50000;PROTOCOL=TCPIP";
var connStr = "DATABASE=demo1;HOSTNAME=10.10.3.12;UID=db2inst1;PWD=12345678;PORT=50000;PROTOCOL=TCPIP;CHARSET=utf8";

process.env.DB2CODEPAGE = 1208
ibmdb.open(connStr, function (err,conn) {
  if (err) return console.log(err);
  
  // conn.query("SELECT TOPNAME FROM test1.ITSM_UNIONQUERYVIEW WHERE CODE='20230228019'", function (err, data) {
  // conn.query("SELECT TOPNAME FROM test1.ITSM_UNIONQUERYVIEW WHERE CODE='666'", function (err, data) {
  conn.query("SELECT TOPNAME FROM test1.ITSM_UNIONQUERYVIEW WHERE CODE='888'", function (err, data) {
    if (err) console.log(err);
    else console.log(data);

    conn.close(function () {
      console.log('done');
    });
  });
});

// ibmdb.open(connStr).then(
//     conn => {
//       conn.query("select 1 from sysibm.sysdummy1").then(data => {
//         console.log(data);
//         conn.closeSync();
//       }, err => {
//         console.log(err);
//       });
//     }, err => {
//       console.log(err)
//     }
// );